package com.yyp.car.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.yyp.car.Iservice.ICarTypeService;
import com.yyp.car.model.CarType;

@Controller
@RequestMapping("/carType")
public class CarTypeController {
	@Resource(name="carTypeService")
	private ICarTypeService carTypeService;
	
	@RequestMapping("/addCarType")
	public String addcarType(CarType carType){
		carTypeService.addCarType(carType);
		return "redirect:/back/carTypeManager";
	}
	
	@RequestMapping("/updateCarType")
	public String updatecarType(CarType carType,String oldName){
		carTypeService.updateCarType(carType,oldName); 
		return "redirect:/back/carTypeManager";
	}
	
	@RequestMapping("/deleteCarType/{id}")
	public String deletecarType(@PathVariable int id){
		carTypeService.delete(id);
		return "redirect:/back/carTypeManager";
	}

}
